import reqAddress from '../req-set.js'

let state = {
	trackList: [],

}
let mutations={
	setTrackList(state,v){
		state.trackList=v
	}
}
let actions={
	reqSeedGetTrakList(store,param){
		store.commit('setTrackList',"")
		console.log(param.gidAary)
		return new Promise((resolve,reject)=>{
			uni.request({
				url:`${reqAddress}/goods/history`,
				data:{
					ids:param.gidAary
				},
				success: (resp) => {
					console.log(resp.data)
					let temp = resp.data.goods
					//渲染时使用 ---------- --- --- -  -
					for (let i = 0; i < temp.length; i++) {
						temp[i].src = 'https://img.alicdn.com/bao/uploaded/i2/915497723/O1CN01Cqq4tK26vBNKEzU6M_!!0-item_pic.jpg'
						temp[i].show = true
						temp[i].loaded = false
					}
					
					// let tempAry=temp.splice(temp.length-20)
					
					store.commit("setTrackList",temp)
					resolve('成功')
				},
				fail: (err) => {
					console.log(err)
					reject(err)
				}
			})
		})
	}
}
	
let track_idx={
	state,mutations,actions
}
export default track_idx